package cn.tqfeiyang.springplus.framework.conversion;

import jakarta.annotation.Resource;
import org.modelmapper.ModelMapper;
import org.springframework.stereotype.Service;

@Service
public class ConversionServiceImpl implements ConversionService {

    @Resource
    private ModelMapper modelMapper;

    /**
     * 将原始对象转换成对应的目标类型
     *
     * @param source 原始对象
     * @param destinationType 目标类型
     * @return
     */
    @Override
    public <D> D map(Object source, Class<D> destinationType) {
        return modelMapper.map(source, destinationType);
    }
}
